package com.szpx.controller.ZRZController;

import com.szpx.service.XueyuanService;
import com.szpx.entity.ZRZ.Xueyuan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/api/xueyuan")
public class XueyuanController {

    @Autowired
    private XueyuanService xueyuanService;

    @GetMapping("/{id}")
    public Xueyuan getById(@PathVariable Integer id) {
        return xueyuanService.getById(id);
    }

    @GetMapping("/all")
    public List<Xueyuan> getAll() {
        System.out.println("查询所有");
        return xueyuanService.getAll();
    }

    @PostMapping("/add")
    public boolean save(@RequestBody Xueyuan xueyuan) {
        System.out.println("添加学院");
        return xueyuanService.save(xueyuan);
    }

    @PutMapping
    public boolean update(@RequestBody Xueyuan xueyuan) {
        return xueyuanService.update(xueyuan);
    }

    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Integer id) {
        return xueyuanService.delete(id);
    }

    @GetMapping("/idCard/{idCard}")
    public Xueyuan getByIdCard(@PathVariable String idCard) {
        return xueyuanService.getByIdCard(idCard);
    }
}